#include<bits/stdc++.h>
using namespace std;
int n,cnt;
int used[2*100000+45],a[2*100000+45];//,f[50000][3000];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	bool ok=0,ki=!a[1];
	while(cnt<n){
		for(int i=1;i<=n;i++){
			if(!used[i]) {
				ki=!a[i];break;
			}
		}
		for(int i=1;i<=n;i++){
			if(ki!=a[i]&&used[i]==0) {
				cout<<i<<" ";
				used[i]=1;
				ki=a[i];
				cnt++;
			}
		}
		cout<<endl;
	}
	return 0;
}/*20
1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0 0 0*/
